import org.apache.sparkimport
org.apache.spark.sql.SparkSession
object TestTextFile {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession.builder()
      .appName("RDDPartitionExample")
      .master("local[*]")
      .getOrCreate()
    val sc = spark.sparkContext
    val first_half = sc.textFile("D:\\Employee_salary_first_half.csv")
    val drop_first = first_half.mapPartitionsWithIndex((ix,it) => {
      if (ix == 0 ) it.drop(1)
      it    })
    val split_first = drop_first.map(line => {
      val data = line.split(",");
      (data(1),data(6).toInt)
    })
    val sort_first = split_first.sortBy(x => x._2,false)
    println(sort_first.take(3).mkString(" "))  }}
